package com.example.demo.controller;


import com.example.demo.dto.ResponseResult;
import com.example.demo.entity.VoicePlan;
import com.example.demo.service.impl.VoicePlanServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("app/service")
public class VoicePlanController {

    @Autowired
    VoicePlanServiceImpl voicePlanServiceImpl;
    //这是一个接口通过判断类别来返回具体的内容
    @GetMapping("/get/all")
    public ResponseResult<List<VoicePlan>> getVoicePlanAll() {
        List<VoicePlan> voicePlans = voicePlanServiceImpl.getPlansByCategoryOrderByPriceAsc();
        return new ResponseResult<>(200,"获取成功", voicePlans);
    }

    //通过服务id来查询服务信息
    @GetMapping("/get/{id}")
    public ResponseResult<VoicePlan> getVoicePlan(@PathVariable int id) {
        VoicePlan voicePlan = voicePlanServiceImpl.getPlanById(id);
        return new ResponseResult<>(200,"获取成功", voicePlan);
    }
}
